package com.zbkj.crmeb.supplier.service.impl;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import javax.annotation.Resource;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.common.CommonPage;
import com.common.PageParamRequest;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.zbkj.crmeb.store.dao.CustomsRecordDao;
import com.zbkj.crmeb.store.request.SupplierOpenShopProductRequest;
import com.zbkj.crmeb.store.response.SupplierOpenShopProductResponse;
import com.zbkj.crmeb.supplier.dao.SupplierOpenShopProductDao;
import com.zbkj.crmeb.supplier.model.SupplierOpenShopProduct;
import com.zbkj.crmeb.supplier.service.SupplierOpenShopProductService;


@Service("supplierOpenShopProductService")
public class SupplierOpenShopProductServiceImpl extends ServiceImpl<SupplierOpenShopProductDao, SupplierOpenShopProduct> implements SupplierOpenShopProductService {

    @Resource
    private SupplierOpenShopProductDao supplierOpenShopProductDao;

    private static final Logger logger = LoggerFactory.getLogger(SupplierOpenShopProductServiceImpl.class);

    /**
     * 列表
     * @param request 请求参数
     * @param pageParamRequest 分页类参数
     * @author Mr.Zhang
     * @since 2020-05-27
     * @return List<StoreProduct>
     */
    @Override
    public PageInfo<SupplierOpenShopProductResponse> getList(SupplierOpenShopProductRequest request, PageParamRequest pageParamRequest) {
        //条件查询
        Page<SupplierOpenShopProduct> supplierOpenShopProductPage = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
        List<SupplierOpenShopProductResponse> supplierOpenShopProducts = supplierOpenShopProductDao.queryList(request);
        if(CollectionUtils.isEmpty(supplierOpenShopProducts)) {
            return CommonPage.copyPageInfo(supplierOpenShopProductPage, new ArrayList<>());
        }

        return CommonPage.copyPageInfo(supplierOpenShopProductPage, supplierOpenShopProducts);
    }

}